package com.backend.controller.student;


import com.backend.common.result.Result;
import com.backend.pojo.dto.LeaveRequestDTO;
import com.backend.pojo.entity.CourseMaterial;
import com.backend.service.CourseService;
import com.backend.service.StuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
@Slf4j
public class StudentController {
    @Autowired
    private StuService stuService;


    @Autowired
    private CourseService courseService;

    @GetMapping("/lesson")
    public Result<List<CourseMaterial>> getAllCourseMaterial(CourseMaterial courseMaterial){

        log.info("开始查啊啊啊啊啊询：{}" , courseMaterial);

        List<CourseMaterial> courseMaterials = courseService.CourseQuery(courseMaterial);

        return Result.success(courseMaterials);
    }

    @PostMapping("/leave")
    public Result stuleave(@RequestBody LeaveRequestDTO leaveRequestDTO){
        log.info("学生请假:{}",leaveRequestDTO);
        stuService.leave(leaveRequestDTO);
        return Result.success();
    }

    @GetMapping
    public Result<List<CourseMaterial>> getAll( ){

        log.info("开始查询：{}" );

        List<CourseMaterial> courseMaterials = courseService.getAll();

        return Result.success(courseMaterials);
    }


}
